package com.hzqy.commons.utils;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class LastDayUtils {
	private static final Log LOG = LogFactory.getLog(LastDayUtils.class);
	
	public static Map<String,Object>  getLastDay(String Str) {
		Map<String,Object> map=new HashMap<String,Object>();
		SimpleDateFormat sDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String dayStr="";
		boolean success=true;
		try {
			Date endDate=sDateFormat.parse(Str);
            Date currDate = new Date();
            long diff = endDate.getTime() - currDate.getTime();
            diff = diff>0?diff:0;
            long days = diff / (1000 * 60 * 60 * 24);
            if(diff % (1000 * 60 * 60 * 24)>0){
            	days+=1;
            }
            dayStr=days+"天";
            /*long hours = (diff - days * (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
            long minutes = (diff - days * (1000 * 60 * 60 * 24) - hours * (1000 * 60 * 60)) / (1000 * 60);
            long seconds = (diff - days * (1000 * 60 * 60 * 24) - hours * (1000 * 60 * 60) - minutes * (1000 * 60)) / (1000);*/
        } catch (Exception e) {
        	success=false;
        	//LOG.error("获取倒计时失败："+e.getMessage());
        }
		map.put("result", dayStr);
		map.put("success", success);
		return map;
	}
	public static void main(String args[]) throws Exception {
	}
}
